<?php
$page=isset($_GET['page'])?$_GET['page']:1;//检测page是否传值
$size=isset($_GET['limit'])?$_GET['limit']:6;//分页条数为6

$redis=new Redis();//实劣化redis
$redis->connect('127.0.0.1',6379);//链接redis
if($redis->Hexists('kook',"page$page"))
{
    $redis->hGet('kook',"page$page");//获取数据的值
}
else
{
    include "show2.php";//调用show2.php
    $dbh = new BDO('127.0.0.1', 'root', 'root');//链接数据
    $count=$dbh->getNamber("games");//求总页数
    $limit=$dbh->getAll("games",$limit,$size);//获取页码和条数
    $data="";
}

if(!$data)//接口处理
{
    $arr['code']=1;
    $arr['msg']="失败";
    $data['data']="";
    $arr['count']="";
    echo json_encode($arr);
}

    $arr['code']=0;
    $arr['msg']="成功";
    $data['data']=$data;
    $arr['count']=$count;
    echo json_encode($arr);

$redis->hSet('kook',"page$page",json_encode($data));
?>